﻿<#escape x as x?html>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>主界面</title>
    <link rel="stylesheet" type="text/css" href="${rc.contextPath}/Resources/style/style.css">
    <link rel="stylesheet" type="text/css" href="${rc.contextPath}/Resources/style/tablestyle.css">
    <script type="text/javascript" src="${rc.contextPath}/Resources/js/jquery-1.8.0.min.js"></script>
    <script type="text/javascript" src="${rc.contextPath}/Resources/js/share.js"></script>
    <script type="text/javascript" src="${rc.contextPath}/Resources/js/json2.js"></script>
    <script type="text/javascript" src="${rc.contextPath}/Resources/js/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="${rc.contextPath}/Resources/js/jquery.linkbutton.js"></script>
    <script type="text/javascript" src="${rc.contextPath}/Resources/js/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="${rc.contextPath}/Resources/js/jquery.datebox.js"></script>
    <script type="text/javascript" src="${rc.contextPath}/Resources/js/jquery.url.js"></script>
    <link rel="stylesheet" type="text/css" href="${rc.contextPath}/Resources/style/easyui.css">
    <link rel="stylesheet" type="text/css" href="${rc.contextPath}/Resources/style/icon.css">
    <style type="text/css">
		body,td,th {
			font-family: "Microsoft YaHei";
		}
		a:visited {
			color: #44655C;
		}
		a:active {
			color: #2A3643;
		}
		a:hover {
			color: #293542;
		}
	</style>
	<script type="text/javascript">
		/////////////////////////////////////
        var username = "${Session["currentUser"].username}";
        var fullName = "${Session["currentUser"].fullName}";
        var role = "${Session["currentUser"].role}";
		function hideLi() {
			if (role == 1) {
				$("#enter_qx").show();
				$("#gl_qx").hide();
			} else if (role == 2) {
				$("#enter_qx").show();
				$("#gl_qx").show();
			} else {
				$("#enter_qx").hide();
				$("#gl_qx").hide();
			}
		}
		function changeQx(i) {
			var flag = $('#qx' + i).text();
			if (flag == '授予权限') {
				$.ajax({
			        type: 'POST',
			        url:  "user/setUserRole?userIds=" + i + "&roleType=1",
			        dataType: "json",
			        success: function (data) {
			        	alert("授权成功！");
			        	$('#qx' + i).text("取消权限");
			        }
		    	});
			} else {
				$.ajax({
			        type: 'POST',
			        url:  "user/setUserRole?userIds=" + i + "&roleType=0",
			        dataType: "json",
			        success: function (data) {
			        	alert("取消成功！");
			        	$('#qx' + i).text("授权权限");
			        }
			    });
			}
		}
		
		function deleteRecord(id) {
			$.ajax({
		        type: 'POST',
		        url:  "dutyrecord/remove/" + id + "",
		        dataType: "json",
		        success: function (data) {
		        	if (data.result == 1) {
		        		alert("删除成功！");
		        		loadList();
		        	} else {
		        		alert("删除失败！");
		        	}
		        }
		    });
		}

		function prevSQPage() {
			goToSQPage($('#currentPage').val() - 1);
		}
		
		function nextSQPage() {
			goToSQPage(parseInt($('#currentPage').val()) + 1);
		}
		 function goToSQPage(page) {
            var $records = $('#records');
            var $pager = $('#pager');
            var $currentPage = $('#currentPage');
            var $totalPages = $('#totalPages');
            var $totalCount = $('#totalCount');
    		$currentPage.val(page);
            var roleType = "";
            if ($('#RadioGroup1_0').is(":checked")) {
            	roleType = "1";
            } else {
            	roleType = "0";
            }
        	 $.ajax({
		        type: 'POST',
		        url:  "user/query?roleType=" + roleType + "&rows=13&page=" + $currentPage.val(),
		        dataType: "json",
		        success: function (data) {
		        	var content = '<tr style="height:50px;"><th bgcolor="#DDDDDD"scope="col">ID</th><th bgcolor="#DDDDDD" scope="col">用户名</th><th bgcolor="#DDDDDD"scope="col">姓名</th><th bgcolor="#DDDDDD"scope="col">操作</th></tr>';;
		            for (var i in data.rows) {
                        var entityJson = JSON.stringify(data.rows[i]);
		            	content += "<tr><td style='text-align:center;'>" + data.rows[i].id + "</td><td style='text-align:center;'>" + data.rows[i].username + "</td><td style='text-align:center;'>" + data.rows[i].fullName + "</td>";
		            	if (data.rows[i].role != 0) {
		            		content += "<td style='text-align:center;'><a id='qx" + data.rows[i].id + "' onclick='changeQx(" + data.rows[i].id + ");'>取消权限</a></td></tr>";
		            	} else {
		            		content += "<td style='text-align:center;'><a id='qx" + data.rows[i].id + "'  onclick='changeQx(" + data.rows[i].id + ");'>授予权限</a></td></tr>";
		            	}
		            }
		            $records.html(content);
		            var count = data.total;
		            var pageSize = 13;
		            var pageNum = parseInt(count / pageSize);
		            if (count % pageSize != 0) {
		            	pageNum++;
		            }
		            $totalPages.val(pageNum);
		            $totalCount.val(count);
		            var pageContent = "上一页<";
		            if ($currentPage.val() > 1) {
		            	pageContent = "<a onclick='prevSQPage();'>上一页</a><";
		     		}
		            if (pageNum > 10) {
		            	
		            } else {
		            	for (var i = 1; i <= pageNum; i++) {
		            		if ($currentPage.val() != i ) {
		            			pageContent += "&nbsp;<a onclick='goToSQPage(" + i + ")'>" + i + "</a>&nbsp;";
		            		} else {
		            			pageContent += "&nbsp;" + i + "&nbsp;";
	            			}
		            	}
		            }
		            if ($currentPage.val() < $totalPages.val()) {
		            	pageContent += "><a onclick='nextSQPage();'>下一页</a>";
		            } else {
		            	pageContent += ">下一页";
		            }
		            $pager.html(pageContent);
		        }
	        });
        }
		/////////////////////////////////////
		function gotoPage() {
			var pageIndex = $("#toPage").val();
			// 此处添加数字判断
			if (0 < pageIndex && pageIndex <= $('#totalPages').val()) {
				goToQXPage(pageIndex);
			} else {
				alert("请正确输入需要跳转的页码");
			}
		}
		function search() {
			if($("#selectItem").combobox("getValue") == null || $("#selectItem").combobox("getValue") == "") {
				alert("请首先选择下拉框，并输入关键字！");
			} else {
				if($("#key").val() == null || $("#key").val() == "") {
					alert("请首先输入关键字！");
				} else {
					goToQXPage(1);
				}
			}
		}
		function prevQXPage() {
			goToQXPage($('#currentPage').val() - 1);
		}
		function nextQXPage() {
			goToQXPage(parseInt($('#currentPage').val()) + 1);
		}
		 function goToQXPage(page) {
		 	if (page == "" || page == null) {
		 		return;
		 	}
            var $records = $('#records');
            var $pager = $('#pager');
            var $currentPage = $('#currentPage');
            var $totalPages = $('#totalPages');
            var $totalCount = $('#totalCount');
    		 $currentPage.val(page);
		     var pageSize = 24;
    		 var filter = "";
    		 var selectItem = $('#selectItem').combobox('getValue');
    		 var key = $('#key').val();
    		 if (selectItem == "") {
    		 	
    		 } else {
    		 	filter = selectItem + " like '%" + key + "%'";
    		 }
        	 $.ajax({
		        type: 'POST',
		        url:  "record/query",
		        data: {
		        	filter:filter,
		        	rows:pageSize,
		        	page:$currentPage.val()
		        },
		        dataType: "json",
		        success: function (data) {
		        	var content = '<tr style="height:50px;"><th  width="50" bgcolor="#DDDDDD"scope="col">序号</th><th bgcolor="#DDDDDD" scope="col">观察内容标题</th><th width="100" bgcolor="#DDDDDD"scope="col">观察日期</th><th width="80" bgcolor="#DDDDDD"scope="col">观察时间</th><th bgcolor="#DDDDDD" scope="col">观察区域</th><th bgcolor="#DDDDDD" scope="col">观察单位</th><th bgcolor="#DDDDDD" scope="col">观察人</th><th width="50" bgcolor="#DDDDDD"scope="col">查看</th></tr>';
		            for (var i in data.rows) {
                        var entityJson = JSON.stringify(data.rows[i]);
                        if($.browser.msie) {
                        	content += "<tr><td>" + data.rows[i].id + "</td><td>" + data.rows[i].observateContentTitle + "</td><td>" + data.rows[i].observateDate + "</td><td>" + data.rows[i].observateTime + "</td><td>" + data.rows[i].checkArea.area + "</td><td>" + data.rows[i].observateWorkUnit + "</td><td>" + data.rows[i].observator + "</td><td><a onclick='ieShowTip(" + entityJson + ")'>查看</a></td></tr>";
		            	} else {
	                        content += "<tr><td>" + data.rows[i].id + "</td><td>" + data.rows[i].observateContentTitle + "</td><td>" + data.rows[i].observateDate + "</td><td>" + data.rows[i].observateTime + "</td><td>" + data.rows[i].checkArea.area + "</td><td>" + data.rows[i].observateWorkUnit + "</td><td>" + data.rows[i].observator + "</td><td><a onclick='showTip(event, " + entityJson + ")'>查看</a></td></tr>";
		            	}
		            	
		            }
		            $records.html(content);
		            var count = data.total;
		            var pageNum = parseInt(count / pageSize);
		            if (count % pageSize != 0) {
		            	pageNum++;
		            }
		            $totalPages.val(pageNum);
		            $totalCount.val(count);
		            var pageContent = "上一页&nbsp;<";
		            if ($currentPage.val() > 1) {
		            	pageContent = "<a style='font-color:green;' onclick='prevQXPage();'>上一页&nbsp;</a><";
		     		}
		            if (pageNum > 10) {
		            	
		            } else {
		            	for (var i = 1; i <= pageNum; i++) {
		            		if ($currentPage.val() != i ) {
		            			pageContent += "&nbsp;<a style='font-color:green;' onclick='goToQXPage(" + i + ")'>" + i + "</a>&nbsp;";
		            		} else {
		            			pageContent += "&nbsp;" + i + "&nbsp;";
	            			}
		            	}
		            }
		            if ($currentPage.val() < $totalPages.val()) {
		            	pageContent += "><a style='font-color:green;' onclick='nextQXPage();'>&nbsp;下一页</a>";
		            } else {
		            	pageContent += ">&nbsp;下一页";
		            }
		            pageContent += "&nbsp;&nbsp;&nbsp;共" + count + "页 &nbsp;&nbsp;" + pageSize + "条记录/每页";
		            pageContent += '&nbsp;&nbsp;&nbsp;&nbsp;<input id="toPage" name="toPage" type="text" style="width:25px;" />&nbsp;&nbsp;&nbsp;&nbsp;<a class="round dark" onclick="gotoPage();">跳 转</a>';
		            $pager.html(pageContent);
		        }
	        });
        }
		$(function() {
			var now=new Date();
			var $d = $('#now');
			$d.html("<span style='padding-left:46px;'>今天是"+now.getFullYear() + "年" + (now.getMonth()+1) + "月"+ now.getDate() + "日</span>");
			//////////////////////////////////////////////////////
			loadList();
			//////////////////////////////////////////////////////
		});
		function loadList() {
			var $content = $('#contont');
			$content.load('list', function() {
			 $("ul.accordion a.item").click(function ()
		            {
		                    $("ul.inner").slideUp("fast");
		                    $(this).parent("li").find("ul.inner").slideDown("fast");
		            })
	
	            $("div.panel a.expand").click(function ()
	            {
	                if ($(this).hasClass("off")) {
	                    $(this).removeClass("off");
	                    $(this).parents(".panel").find(".content").slideDown("fast");
	                }
	                else {
	                    $(this).addClass("off");
	                    $(this).parents(".panel").find(".content").slideUp("fast");
	                }
	            })
			     $('#selectItem').combobox({
		            valueField: 'colName',
		            textField: 'fullname',
		            data: 
		            [
		            	{
		            		"colName" : "observateContentTitle",
		            		"fullname" : "观察内容标题"
		            	},
		            	{
		            		"colName" : "observateDate",
		            		"fullname" : "观察日期"
		            	},
		            	{
		            		"colName" : "observateTime",
		            		"fullname" : "观察时间"
		            	},
		            	{
		            		"colName" : "observateWorkUnit",
		            		"fullname" : "观察单位"
		            	},
		            	{
		            		"colName" : "observator",
		            		"fullname" : "观察人"
		            	}
		            ]
		        });
            	goToQXPage(1);
				hideLi();
			});
		}
		function loadText() {
			var $content = $('#contont');
			$content.load('text', function() {
				 $("ul.accordion a.item").click(function ()
		            {
		                    $("ul.inner").slideUp("fast");
		                    $(this).parent("li").find("ul.inner").slideDown("fast");
		            })
	
	            $("div.panel a.expand").click(function ()
	            {
	                if ($(this).hasClass("off")) {
	                    $(this).removeClass("off");
	                    $(this).parents(".panel").find(".content").slideDown("fast");
	                }
	                else {
	                    $(this).addClass("off");
	                    $(this).parents(".panel").find(".content").slideUp("fast");
	                }
	            })
	            $("#addTime").datetimebox({
			    	editable: false
			    });
	            $("#observateDate").datebox({
			    	editable: false
			    });
	            $("#completeDate").datebox({
			    	editable: false
			    });
				hideLi();
			});
		}
		function loadAuthority() {
			var $content = $('#contont');
			$content.load('authority', function() {
		 		$("ul.accordion a.item").click(function ()
		            {
		                    $("ul.inner").slideUp("fast");
		                    $(this).parent("li").find("ul.inner").slideDown("fast");
		            })
	
	            $("div.panel a.expand").click(function ()
	            {
	                if ($(this).hasClass("off")) {
	                    $(this).removeClass("off");
	                    $(this).parents(".panel").find(".content").slideDown("fast");
	                }
	                else {
	                    $(this).addClass("off");
	                    $(this).parents(".panel").find(".content").slideUp("fast");
	                }
	            })
            	goToSQPage(1);
				hideLi();
			});
		}
	</script>
</head>
<body>
    <div class="header">
        <img class="logo" src="${rc.contextPath}/Resources/images/bgs/logincio.png">
        <div class="divide"></div>
        <div class="func">
            <a class="button round dark" href="#">首&nbsp;页</a>
            <a class="button round blood" onclick="loginout();">退&nbsp;出</a>
        </div>
    </div>
   
    <div class="tool">
        <div id="now" class="info"></div>
        <ul class="trace" style="margin-top: 0px;">
            <li><a href="#"><img class="png" src="${rc.contextPath}/Resources/images/icon/icon_home.png" /></a></li>
            <li><a href="#">常规管理</a></li>
        </ul>
    </div>
    <div id="contont"></div>
    <input id='updateId' type='hidden'>
    <div class="footer">独山子石化原油处</div>
</body>

</html>
</#escape>